package com.cnebula.openapi.auth;

import io.vertx.core.json.JsonObject;

public class AuthOptions {
	
	public static final String CLI_HOST = "host";
	public static final String CLI_PORT = "port";
	public static final String CLI_LSP_HOST = "lsp.host";
	public static final String CLI_LSP_PORT = "lsp.port";
	public static final String CLI_OKAPI_HOST = "okapi.host";
	public static final String CLI_OKAPI_PORT = "okapi.port";
	public static final String CLI_ENV_DEV = "env.dev";
	public static final String CLI_LP_SECRET = "lp.secret";
	public static final String CLI_REIDS_HOST = "redis.host";
	public static final String CLI_REIDS_PORT = "redis.port";
	
	
	public static final String DEFAULT_HOST = "192.168.2.43";
	public static final int DEFAULT_PORT = 8081;
	
	public static final String DEFAULT_LSP_HOST = "192.168.2.66";
	public static final int DEFAULT_LSP_PORT = 8082;
	
	public static final String DEFAULT_OKAPI_HOST = "192.168.2.66";
	public static final int DEFAULT_OKAPI_PORT = 9130;
	
	public static final String DEFAULT_LP_SECRET = "lp_secret";
	
	public static final String OKAPI_TENANT = "X-Okapi-Tenant";
	
	public static final String DEFAULT_ENV_DEV = "no";
	
	public static final String DEFAULT_REDIS_HOST = "127.0.0.1";
	public static final int DEFAULT_REDIS_PORT = 6379;
	
	
	
	private String host;
	private int port;
	private String lspHost;
	private int lspPort;
	private String okapiHost;
	private int okapiPort;
	private String lpSecret;
	private String envDev;
	private String redisHost;
	private int redisPort;
	
	public AuthOptions(){
		init();
	}
	public AuthOptions(AuthOptions other){
		this.host = other.host;
		this.port = other.port;
		this.lspHost = other.lspHost;
		this.lspPort = other.lspPort;
		this.lpSecret = other.lpSecret;
		this.okapiHost = other.okapiHost;
		this.okapiPort = other.okapiPort;
	}
	
	public AuthOptions(JsonObject config){
		this.host = config.getString(CLI_HOST, DEFAULT_HOST);
		this.port = config.getInteger(CLI_PORT, DEFAULT_PORT);
		this.lspHost = config.getString(CLI_LSP_HOST, DEFAULT_LSP_HOST);
		this.lspPort = config.getInteger(CLI_LSP_PORT, DEFAULT_LSP_PORT);
		this.okapiHost = config.getString(CLI_OKAPI_HOST, DEFAULT_OKAPI_HOST);
		this.okapiPort = config.getInteger(CLI_OKAPI_PORT, DEFAULT_OKAPI_PORT);
		this.lpSecret = config.getString(CLI_LP_SECRET, DEFAULT_LP_SECRET);
		this.envDev = config.getString(CLI_ENV_DEV, DEFAULT_ENV_DEV);
		this.redisHost = config.getString(CLI_REIDS_HOST, DEFAULT_REDIS_HOST);
		this.redisPort = config.getInteger(CLI_REIDS_PORT, DEFAULT_REDIS_PORT);
	}
	
	private void init(){
		this.host = DEFAULT_HOST;
		this.port = DEFAULT_PORT;
		this.lspHost = DEFAULT_LSP_HOST;
		this.lspPort = DEFAULT_LSP_PORT;
		this.okapiHost = DEFAULT_OKAPI_HOST;
		this.okapiPort = DEFAULT_OKAPI_PORT;
		this.lpSecret = DEFAULT_LP_SECRET;
		this.envDev = DEFAULT_ENV_DEV;
		this.redisHost = DEFAULT_REDIS_HOST;
		this.redisPort = DEFAULT_REDIS_PORT;
	}
	public String getHost() {
		return host;
	}
	public int getPort() {
		return port;
	}
	public String getLspHost() {
		return lspHost;
	}
	public int getLspPort() {
		return lspPort;
	}
	public String getLpSecret() {
		return lpSecret;
	}
	public String getEnvDev() {
		return envDev;
	}
	public String getOkapiHost() {
		return okapiHost;
	}
	public int getOkapiPort() {
		return okapiPort;
	}
	public String getRedisHost() {
		return redisHost;
	}
	public int getRedisPort() {
		return redisPort;
	}
}
